import { CopyControllerBase } from "./CopyControllerBase";
import { IView } from "../../../../mvc/interfaces/IView";
import { FaneCopyInfoPanel } from "../faneCopy/FaneCopyInfoPanel";
import { NetDispatcher } from "../../../../mvc/core/NetDispatcher";
import { EPublicCommand } from "../../../../../Message/Command/EPublicCommand";
import { TCopy } from "../../../../../Message/Db/Tables/TCopy";
import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SCopyChoiceTempleInfo } from "../../../../../Message/Public/SCopyChoiceTempleInfo";
//class FaneCopyController
    
    export  class FaneCopyController extends CopyControllerBase
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ initView(): IView
        {
            if (!this._infoPanel) 
            {
                this._infoPanel = new FaneCopyInfoPanel();
            }
            this._infoPanel.updatePosition();
            return this._infoPanel;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            NetDispatcher.addCmdListener(EPublicCommand._ECmdPublicCopyChoiceTempleKillBoss, this.onKillBossHandler);
            return;
        }

        public /* override */ enterCopy(arg1: TCopy): void
        {
            super.enterCopy(arg1);
            view.show();
            this._infoPanel.showPanel();
            this._infoPanel.updateByCopyInfo(cache.copy.copyInfo);
            this._infoPanel.updateByTempleInfo(this._info);
            return;
        }

        public /* override */ leaveCopy(): void
        {
            super.leaveCopy();
            if (this._infoPanel) 
            {
                this._infoPanel.hide();
            }
            this._info = null;
            return;
        }

        /* internal  */onKillBossHandler(arg1: MessageBlock): void
        {
            var loc1=arg1.messageBase as SCopyChoiceTempleInfo;
            this._info = loc1;
            if (this._infoPanel) 
            {
                this._infoPanel.updateByTempleInfo(loc1);
            }
            return;
        }

        /* internal */ /* var */_infoPanel: FaneCopyInfoPanel;

        /* internal */ /* var */_info: SCopyChoiceTempleInfo;
    }
